[16.0][FIX] website_sale_stock_available#1213
Closed
SuShanVoong wants to merge 2 commits into
Closed
Conversation
|
LGTM! |
LuisAlejandroS
approved these changes
May 27, 2026
Replace the explicit _compute_available_quantities() call with a batch read(["immediately_usable_qty"]) so the standard ORM prefetch path is used instead of binding to a specific compute method. Forward lot_id/owner_id/package_id/from_date/to_date to with_context() so immediately_usable_qty is computed with the same parameters as the super() result, preventing args/context incoherence. Update test to spy on _compute_available_quantities and assert it is invoked once for the whole recordset, addressing the prefetch question raised in the upstream review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
It was identified that within the
website_sale_stock_availablemodule, when computing stock quantities for a recordset of multiple products with thewebsite_sale_stock_availablecontext flag enabled, the_compute_quantities_dictoverride iterated the recordset one product at a time, readingproduct.immediately_usable_qtyon each single-record recordset.Cases Covered with This Improvement
/shop/category/... pageswhere multiple product cards are displayed and the stock cascade is evaluated for each one._compute_quantities_dicton a multi-product recordset with website_sale_stock_available=True in context (for example bulk queries from API endpoints or batched reports).Implemented Solution
The
_compute_quantities_dictoverride has been refactored to invoke_compute_available_quantitiesonce on the full recordset before iterating. This pre-warm populates the ORM cache forimmediately_usable_qtyfor every product at once, so the subsequent per-record reads inside the loop hit the cache instead of re-triggering the compute and the underlying cascade.The behavior is functionally equivalent: the returned free_qty for each product still equals its
immediately_usable_qty, just as before. Only the number of times the cascade executes changes — from N+1 to a single invocation on the full recordset.FL-666-8676